{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 学习使用matplotlib绘图\n",
    "\n",
    "## 第一节 安装并绘制\n",
    "# 1、安装包\n",
    "\n",
    "~~~shell\n",
    "$ pip install matplotlib\n",
    "~~~\n",
    "\n",
    "# 2、进入python的交互式界面\n",
    "\n",
    "~~~shell\n",
    "$ python -i\n",
    "~~~\n",
    "\n",
    "# 3、使用 matplotlib 的 scatter 方法绘制散点图\n",
    "~~~python\n",
    "import matplotlib.pyplot as plt\n",
    "x = [1, 2, 3, 4, 5]\n",
    "y = [2.3, 3.4, 1.2, 6.6, 7.0]\n",
    "plt.scatter(x, y, color='r', marker='+')\n",
    "~~~\n",
    "# 4、输出结果\n",
    "输出一个最终图表效果的窗口。\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "pycharm": {
     "name": "#%%\n"
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<matplotlib.collections.PathCollection at 0x7f2f6811bef0>"
      ]
     },
     "execution_count": 1,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAWoAAAD4CAYAAADFAawfAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4yLjEsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy+j8jraAAAM6klEQVR4nO3d349cd33G8eepbQpNIiLhEY3ilO0VUkElcUdWUFC0TRREAIWL5sJI0AapstqikggkVHpRRP8ARH9IRVbSNi0JPxTiKrVIRKRkjbjAaNYxkMRplSIjElI8oSI/aAVyeHoxZ531etZzJsyZ+djzfkkjz/gcz3n0tefxZ8+cnXUSAQDq+rVFBwAAnB9FDQDFUdQAUBxFDQDFUdQAUNzOLp509+7dWVlZ6eKpAeCitL6+/nyS3rhtnRT1ysqKBoNBF08NABcl2z/YbhunPgCgOI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790m60bYL5FoI23skvU/SndvsMvf1apmrqpm+Hqueo75S0g83PX5GBQqg8c7mS9cHbb9t3gdvvuS8RqNpbLOFrtl5ckkLWLPmy+Xjkk5JejjJtuuV5LSkFyS9qUAuSfqD5svl+2xf1XWmxuckfVLSL7fZvpD1apFLWsx6RdLXba/bPjBm+0xfj1WLuqpjkt6S5B2S/k7Sv83z4LYvlfRVSXckeXGexz6fCbkWsmZJXklytaQ9kvbZfvs8jjtJi1z/Lmklye9KelivTrGdsf1+SaeSrHd9rGm0zDX39Wq8K8leSTdL+qjt67s8WNWiflbS5v8Z9zS/t1BJXtz40jXJ1yTtsr17Hse2vUujMrwnyf1jdlnImk3Ktcg1a475U0mP6tyfUnRmvWzvlPRGST9ZdK4kP0ny8+bhnZJ+bw5xrpN0i+2Tkr4k6QbbX9iyzyLWa2KuBa2Xkjzb/HpK0iFJ+7bsMtPXY9WifkDSHzbvnF4r6YUkzy06lO3f3DgvZ3ufRuvX+Yu7OeZdkk4k+ew2u819zdrkWsSa2e7Zvry5/wZJN0l6astuD0j6o+b+rZIeSfMu0CJzbTmPeYtG5/07leRTSfYkWdHojcJHknxoy25zX682uRaxXrYvsX3Zxn1J75a09Uqxmb4eF/JTyL3pE/lsPyPp0xq9saIkn5f0NY3eNX1a0v9K+kiRXLdK+lPbpyX9n6T9Xf9jbVwn6cOSvtec35Skv5T0W5uyLWLN2uRaxJpdIelu2zs0+o/hK0kO2/5rSYMkD2j0H8y/2n5aozeQ93ecqW2uj9m+RdLpJtdtc8g1VoH1apNrEev1ZkmHmvljp6R7kzxk+0+kbl6PfAs5ABRX9dQHAKBBUQNAcRQ1ABRHUQNAcRQ1ABRHUQNAcRQ1ABT3/+tyeP/wdLzTAAAAAElFTkSuQmCC\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "import matplotlib.pyplot as plt\n",
    "x = [1, 2, 3, 4, 5]\n",
    "y = [2.3, 3.4, 1.2, 6.6, 7.0]\n",
    "plt.scatter(x, y, color = 'r', marker = '+')\n"
   ]
  },
  {
   "cell_type": "markdown",
   "source": [
    "## 第二节 教程\n",
    "\n",
    "### 序言\n",
    "\n",
    "这些教程涵盖了使用 Matplotlib 创建可视化的基础知识，以及有效使用软件包的一些最佳实践。\n",
    "\n"
   ],
   "metadata": {
    "collapsed": false
   }
  },
  {
   "cell_type": "markdown",
   "source": [
    "## 第二节 绘制图\n",
    "\n",
    "### 堆积条形图\n",
    "\n",
    "这是使用`bar`创建带有误差线的堆积条形图的示例。注意yerr用于误差条的参数，并且底部用于将`女人`的条形堆叠在`男人`条形的顶部。"
   ],
   "metadata": {
    "collapsed": false
   }
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "outputs": [],
   "source": [
    "import numpy as np\n",
    "import matplotlib.pyplot as plt\n",
    "\n",
    "N = 5\n",
    "menMeans = (20, 35, 30, 35, 27)\n",
    "womenMeans = (25, 32, 34, 20, 25)\n",
    "menStd = (2, 3, 4, 1, 2)\n",
    "womenStd = (3, 5, 2, 3, 3)\n",
    "ind = np.arange(N)    # the x locations for the groups\n",
    "width = 0.35       # the width of the bars: can also be len(x) sequence\n",
    "\n",
    "p1 = plt.bar(ind, menMeans, width, yerr=menStd)\n",
    "p2 = plt.bar(ind, womenMeans, width, bottom=menMeans, yerr=womenStd)\n",
    "\n",
    "plt.ylabel('Scores')\n",
    "plt.title('Scores by group and gender')\n",
    "plt.xticks(ind, ('G1', 'G2', 'G3', 'G4', 'G5'))\n",
    "plt.yticks(np.arange(0, 81, 10))\n",
    "plt.legend((p1[0], p2[0]), ('Men', 'Women'))\n",
    "\n",
    "plt.show()\n"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%%\n"
    }
   }
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.8"
  },
  "pycharm": {
   "stem_cell": {
    "cell_type": "raw",
    "source": [],
    "metadata": {
     "collapsed": false
    }
   }
  }
 },
 "nbformat": 4,
 "nbformat_minor": 1
}